
package cn.edu.scau.cmi.hombio.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.codehaus.jackson.annotate.JsonIgnore;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllPigHouses", query = "select myPigHouse from PigHouse myPigHouse"),
		@NamedQuery(name = "findPigHouseById", query = "select myPigHouse from PigHouse myPigHouse where myPigHouse.id = ?1"),
		@NamedQuery(name = "findPigHouseByMemo", query = "select myPigHouse from PigHouse myPigHouse where myPigHouse.memo = ?1"),
		@NamedQuery(name = "findPigHouseByMemoContaining", query = "select myPigHouse from PigHouse myPigHouse where myPigHouse.memo like ?1"),
		@NamedQuery(name = "findPigHouseByNumber", query = "select myPigHouse from PigHouse myPigHouse where myPigHouse.number = ?1"),
		@NamedQuery(name = "findPigHouseByPrimaryKey", query = "select myPigHouse from PigHouse myPigHouse where myPigHouse.id = ?1"),
		@NamedQuery(name = "findPigHouseByRfid", query = "select myPigHouse from PigHouse myPigHouse where myPigHouse.rfid = ?1"),
		@NamedQuery(name = "findPigHouseByRfidContaining", query = "select myPigHouse from PigHouse myPigHouse where myPigHouse.rfid like ?1") })

@Table(catalog = "pig", name = "pig_house")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain", name = "PigHouse")
@XmlRootElement(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain")
public class PigHouse implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "Id", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@Id @GeneratedValue
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "Number", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	Integer number;
	/**
	 */

	@Column(name = "RFID", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String rfid;
	/**
	 */

	@Column(name = "Memo")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String memo;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "PigHouseTypeId", referencedColumnName = "Id", nullable = false) })
	@XmlTransient
	PigHouseType pigHouseType;
	/**
	 */
	@OneToMany(mappedBy = "pigHouse", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.Pigsty> pigsties;
	/**
	 */
	@OneToMany(mappedBy = "pigHouse", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.TaskPighouse> taskPighouses;
	/**
	 */
	@OneToMany(mappedBy = "pigHouse", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.Inspection> inspections;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setNumber(Integer number) {
		this.number = number;
	}

	/**
	 */
	public Integer getNumber() {
		return this.number;
	}

	/**
	 */
	public void setRfid(String rfid) {
		this.rfid = rfid;
	}

	/**
	 */
	public String getRfid() {
		return this.rfid;
	}

	/**
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}

	/**
	 */
	public String getMemo() {
		return this.memo;
	}

	/**
	 */
	public void setPigHouseType(PigHouseType pigHouseType) {
		this.pigHouseType = pigHouseType;
	}

	/**
	 */
	@JsonIgnore
	public PigHouseType getPigHouseType() {
		return pigHouseType;
	}

	/**
	 */
	public void setPigsties(Set<Pigsty> pigsties) {
		this.pigsties = pigsties;
	}

	/**
	 */
	@JsonIgnore
	public Set<Pigsty> getPigsties() {
		if (pigsties == null) {
			pigsties = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Pigsty>();
		}
		return pigsties;
	}

	/**
	 */
	public void setTaskPighouses(Set<TaskPighouse> taskPighouses) {
		this.taskPighouses = taskPighouses;
	}

	/**
	 */
	@JsonIgnore
	public Set<TaskPighouse> getTaskPighouses() {
		if (taskPighouses == null) {
			taskPighouses = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPighouse>();
		}
		return taskPighouses;
	}

	/**
	 */
	public void setInspections(Set<Inspection> inspections) {
		this.inspections = inspections;
	}

	/**
	 */
	@JsonIgnore
	public Set<Inspection> getInspections() {
		if (inspections == null) {
			inspections = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Inspection>();
		}
		return inspections;
	}

	/**
	 */
	public PigHouse() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(PigHouse that) {
		setId(that.getId());
		setNumber(that.getNumber());
		setRfid(that.getRfid());
		setMemo(that.getMemo());
		setPigHouseType(that.getPigHouseType());
		setPigsties(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Pigsty>(that.getPigsties()));
		setTaskPighouses(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPighouse>(that.getTaskPighouses()));
		setInspections(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Inspection>(that.getInspections()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("number=[").append(number).append("] ");
		buffer.append("rfid=[").append(rfid).append("] ");
		buffer.append("memo=[").append(memo).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof PigHouse))
			return false;
		PigHouse equalCheck = (PigHouse) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
